package com.sumer.brain.sys.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.sumer.brain.common.model.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Schema(name = "GenTable" , description = "代码生成实体")
@TableName(value = "gen_table")
@Data
public class GenTable extends BaseEntity {

    @Schema(description = "编码")
    @TableId(type = IdType.AUTO)
    private Long tableId;

    @Schema(description = "表名称")
    private String tableName;

    @Schema(description = "表描述")
    private String tableComment;

    @Schema(description = "关联子表的表名")
    private String subTableName;

    @Schema(description = "子表关联的外键名")
    private String subTableFkName;

    @Schema(description = "实体类名称")
    private String className;

    @Schema(description = "使用的模板（crud单表操作 tree树表操作）")
    private String tplCategory;

    @Schema(description = "前端模板类型（element-ui模版 element-plus模版）")
    private String tplWebType;

    @Schema(description = "生成包路径")
    private String packageName;

    @Schema(description = "生成模块名")
    private String moduleName;

    @Schema(description = "生成业务名")
    private String businessName;

    @Schema(description = "生成功能名")
    private String functionName;

    @Schema(description = "生成功能作者")
    private String functionAuthor;

    @Schema(description = "生成代码方式（0zip压缩包 1自定义路径）")
    private String genType;

    @Schema(description = "生成路径（不填默认项目路径）")
    private String genPath;

    @Schema(description = "其它生成选项")
    private String options;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "列信息")
    @TableField(exist = false)
    private List<GenTableColumn> columns;

    @Schema(description = "主键列信息")
    @TableField(exist = false)
    private GenTableColumn pkColumn;

    @Schema(description = "子表信息")
    @TableField(exist = false)
    private GenTable subTable;

    @Schema(description = "树编码字段")
    @TableField(exist = false)
    private String treeCode;

    @Schema(description = "树父编码字段")
    @TableField(exist = false)
    private String treeParentCode;

    @Schema(description = "树名称字段")
    @TableField(exist = false)
    private String treeName;

    @Schema(description = "上级菜单ID字段")
    @TableField(exist = false)
    private String parentMenuId;

    @Schema(description = "上级菜单名称字段")
    @TableField(exist = false)
    private String parentMenuName;

    @Schema(description = "请求参数")
    @TableField(exist = false)
    private Map<String, Object> params;

    public Map<String, Object> getParams() {
        if (params == null) {
            params = new HashMap<>();
        }
        return params;
    }
}